#pragma once
#ifndef __WATER_OBJECT_H__
#define __WATER_OBJECT_H__

#include <Windows.h>
#include <mmsystem.h>
#include <d3dx9.h>

class WaterObject
{
public:
	enum
	{
		WIDTH = 128,
		HEIGHT = 128,
	};
	enum DrawType
	{
		LINE,
		TRIANGLE
	};

	// A structure for our custom vertex type
	struct CUSTOMVERTEX
	{
		FLOAT x, y, z;      // The untransformed, 3D position for the vertex
		DWORD color;        // The vertex color
	};

private:
	DrawType m_draw_type;
	LPDIRECT3DDEVICE9 m_device;
	LPDIRECT3DVERTEXBUFFER9 m_vb; // Buffer to hold vertices
	LPDIRECT3DINDEXBUFFER9 m_ib;

	unsigned int *m_indices;
	CUSTOMVERTEX *m_cur_frame;
	CUSTOMVERTEX *m_pre_frame;

protected:
	void Init();
	void UpdateVertices();
	void UpdateMatrices();

	void SetupVertices();
	void SetupIndices();

	void RippleSpread();

public:
	WaterObject(LPDIRECT3DDEVICE9 device, DrawType draw_type);
	~WaterObject();

	void Update();
	void Render();
	void Release();
	void DropStone(int, int, int, float);
	void SetDrawType(DrawType draw_type);

};

#endif //__WATER_OBJECT_H__